package org.mpremote.android.activities;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.EditText;
import org.mpremote.android.R;
import org.mpremote.android.activities.abstracts.MPActivity;

/**
 * Created by IntelliJ IDEA.
 * User: Gilad
 * Date: 24/08/2010
 * Time: 21:04:41
 */
public class ConfigurationActivity extends MPActivity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final SharedPreferences properties = getProperties();
        setContentView(R.layout.configuration);
        final EditText ipEditText = ((EditText) findViewById(R.id.mp_ip));
        ipEditText.setText(getProperty(R.string.mp_properties_mp_ip, R.string.mp_activity_configuration_ip));
        final EditText portEditTExt = ((EditText) findViewById(R.id.mp_port));
        portEditTExt.setText(getProperty(R.string.mp_properties_mp_port, R.string.mp_activity_configuration_port));
    }

    @Override
    protected void onStop() {
        super.onStop();
        final SharedPreferences properties = getProperties();
        final SharedPreferences.Editor editor = getPropertiesEditor();
        final EditText ipEditText = ((EditText) findViewById(R.id.mp_ip));
        editor.putString(getString(R.string.mp_properties_mp_ip), ipEditText.getText().toString().toLowerCase().trim());
        final EditText portEditText = ((EditText) findViewById(R.id.mp_port));
        editor.putString(getString(R.string.mp_properties_mp_port), portEditText.getText().toString().toLowerCase().trim());
        editor.commit();
    }

}
